package com.w.tank;
import java.util.ArrayList;


public class GameControl {
     ArrayList<GameObject> gameObjects;
    ColliderChain colliderChain;
    public static final GameControl INSTANCE = new GameControl();
    Tank maintank;

    static {
        INSTANCE.init();
    }

    public GameControl(){
        gameObjects = new ArrayList<>();
        colliderChain = new ColliderChain();
    }

    public void init(){

        maintank = new Tank(200,200,Dir.DOWN, Group.GOOD);
        new Wall(60,800, 0,0);
        new Wall(60,300,400,0);
        new Wall(300,60,60, 20);


        for(int i=0;i<5;i++){
            new Tank(200 + i*Tank.WIDTH, 300, Dir.DOWN, Group.BAD);
        }


    }

    public  static GameControl getInstance(){
        return INSTANCE;
    }

    public void deletecoll(){
      for(int i=0;i<gameObjects.size();i++){
          for(int j=i+1; j<gameObjects.size();j++){
              colliderChain.collide(gameObjects.get(i), gameObjects.get(j));
          }
      }
    }


    public int size(){
        return gameObjects.size();
    }


    public GameObject get(int i){
        return gameObjects.get(i);
    }

    public void add(GameObject gameobj){
        gameObjects.add(gameobj);
    }

    public void remove(GameObject gameobj){
        gameObjects.remove(gameobj);
    }






}
